<template>
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="pageIndex"
    :page-sizes="pageSizes"
    :page-size="pageSize"
    layout="total, sizes, prev, pager, next, jumper"
    :total="total"
    :call-back="CallBack"
    :key="+new Date()"
  ></el-pagination>
</template>

<script setup lang="ts">
const emits = defineEmits([
  'update:pageIndex',
  'update:pageSize',
  'update:total',
])
const props = defineProps({
  pageIndex: {
    type: Number,
    default: 1,
  },
  pageSize: {
    type: Number,
    default: 10,
  },
  total: {
    type: Number,
    default: 0,
  },

  pageSizes: {
    type: [Array],
    default: function () {
      return [5, 10, 15, 20]
    },
  },
  CallBack: {
    type: [Function],
    default: function () {
      console.log('66666666666666')
    },
  },
})

const handleSizeChange = (pageSize: number) => {
  emits('update:pageSize', pageSize)
  props.CallBack()
}
const handleCurrentChange = (pageIndex: number) => {
  emits('update:pageIndex', pageIndex)
  props.CallBack()
}
</script>

<style>
.el-pagination {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.el-pagination__jump {
  display: inline-flex !important;
}
</style>
